home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / CMPLTPAS / DTATODIR.PAS < prev    next >
Pascal/Delphi Source File  |  1988-07-14  |  3KB  |  59 lines

  1. {->>>>DTAtoDIR<<<<---------------------------------------------}
  2. {                                                              }
  3. { FILENAME DTATODIR.SRC -- Last modified 11/8/87               }
  4. {                                                              }
  5. { This procedure converts data as returned by DOS FIND         }
  6. { calls $4E & $4F in the Disk Transfer Area (DTA) to a more    }
  7. { tractable form as defined by my own record type DIRRec.      }
  8. { This involves converting the time from a word timestamp to   }
  9. { a TimeRec, and the date from a word datestamp to a DateRec.  }
  10. {                                                              }
  11. { DTAToDIR requires the prior definition of types DIRRec,      }
  12. { DIRPtr, and DTAPtr; and procedures CalcTime and CalcDate.    }
  13. {                                                              }
  14. {     From: COMPLETE TURBO PASCAL 5.0  by Jeff Duntemann       }
  15. {    Scott, Foresman & Co., Inc. 1988   ISBN 0-673-38355-5     }
  16. {--------------------------------------------------------------}
  17.  
  18. PROCEDURE DTAtoDIR(VAR OutRec : DIRRec);
  19.  
  20. VAR
  21.   DTData      : DateTime;   { This type imported from DOS unit }
  22.   I           : Integer;
  23.   InRec       : SearchRec;  { Also imported from the DOS unit  }
  24.   RegPack     : Registers;  { Also imported from the DOS unit  }
  25.   CurrentDTA  : DTAPtr;
  26.  
  27. BEGIN
  28.   RegPack.AX := $2F00; { Find current location of DTA }
  29.   MSDOS(RegPack);
  30.   WITH RegPack DO CurrentDTA := Ptr(ES,BX);
  31.   InRec := CurrentDTA^;
  32.   UnpackTime(InRec.Time,DTData);
  33.   WITH OutRec DO              { Now extract and reformat data }
  34.     BEGIN
  35.       FileName := InRec.Name; { Extract the file name }
  36.       Attrib := InRec.Attr;   { Extract the attribute field }
  37.       WITH TimeStamp DO       { Expand integer time stamp }
  38.         BEGIN
  39.           TimeComp := InRec.Time SHR 16;
  40.           Hours := DTData.Hour;
  41.           Minutes := DTData.Min;
  42.           Seconds := DTData.Sec;
  43.           Hundredths := 0;
  44.         END;
  45.       CalcTime(TimeStamp);   { Fill in the other time fields }
  46.       WITH DateStamp DO      { Expand integer date stamp }
  47.         BEGIN
  48.           DateComp := InRec.Time AND $0000FFFF;
  49.           Day := DTData.Day;
  50.           Month := DTData.Month;
  51.           Year  := DTData.Year;
  52.         END;
  53.       CalcDate(DateStamp);   { Fill in the other date fields }
  54.       FileSize := InRec.Size;
  55.       Next := NIL;            { Initialize the "next" pointer }
  56.       Prior := NIL;           { Ditto the "prior" pointer }
  57.     END
  58. END;  { DTAtoDIR }
  59.